{include file='public/header.html'}
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar" id="sidebar">
            {include file='public/sidebar.html'}
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" id="main">

            <h3 class="page-header">数据还原</h3>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <a href="{:url('index')}">数据备份</a> | <a href="{:url('restore')}" class="active">数据还原</a>
                    <span class="pull-right"><a href="javascript:history.back(-1);">返回</a></span>
                </div>
                <div class="panel-body">
                    <a href="{:url('index')}" class="btn btn-primary">前往备份</a>
                </div>
                <div class="table-responsive">
                    <table class="table table-striped table-bordered">
                        <thead>
                        <tr>
                            <th>备份编号</th>
                            <th>操作</th>
                            <th>备份路径</th>
                            <th>备份时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach $list as $k=>$vo}
                        {php $k=$k+1}
                        <tr>
                            <td>{$vo.name}</td>
                            <td>
                                <a href="javascript:restore('{$vo['path']}');" class="btn btn-primary btn-sm">还原</a>
                                <a href="{:url('bak_down',['path'=>$vo['path']])}" class="btn btn-success btn-sm">下载</a>
                                <a href="javascript:ajaxConfirm('{:url('bak_del',['path'=>$vo['path']])}','删除',2);" class="btn btn-danger btn-sm">删除</a>
                            </td>
                            <td>{$vo.path}</td>
                            <td>{$vo.time}</td>
                        </tr>
                        {/foreach}
                        {empty $list:}
                        <tr>
                            <td colspan="4"> 暂无备份</td>
                        </tr>
                        {/empty}
                        </tbody>
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>

{include file='public/footer.html'}
<script>
    function restore(path) {
        var msg = '确认要还原数据吗？'+path;
        layer.open({content:msg,btn:['确认','取消'],yes:function(index){
                var bak = layer.open({content:'数据还原中，请耐心等待……', shadeClose: false, type: 2});
                $.post("{:url('bak_restore')}",{path:path},function(res){
                    if (res.status === 1) {
                        layer.close(bak);
                        toast(res.msg);
                        setTimeout(function(){
                            window.location.href = res.url;
                        },2000);
                    } else {
                        toast(res.msg);
                    }
                },'json');
                layer.close(index);
            }
        });
    }
</script>
</body>
</html>